import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VueWechatTitle from 'vue-wechat-title';



/**
 * 引入axios，并将axios注入到vue
 */
import '@/service'

Vue.use(ElementUI);
Vue.use(VueWechatTitle);
Vue.config.productionTip = false

//路由验证登录
router.beforeEach(function (to, from, next) {
  
  var token = localStorage.getItem("token");
    
  if(token!=null||to.path==='/login'){
    next();    
  }
  else { 
    if (token === null || token === '') {
      next('/login');
    } 
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
